
/*
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  These are the four essential freedoms with GNU GPL software:
 *  1: freedom to run the program, for any purpose
 *  2: freedom to study how the program works, and change it to make it do what you wish
 *  3: freedom to redistribute copies to help your Free Software girlfriends and friends
 *  4: freedom to distribute copies of your modified versions to your Free Software girlfriends and friends
 *   ,           ,
 *  /             \
 * ((__-^^-,-^^-__))
 * `-_---'  `---_-'
 *  `--|o`   'o|--'
 *      \  `  /
 *       ): :(
 *       :o_o:
 *        "-"
 */


#include "config.h"

#include <stdio.h>

#include "main.h"
#include "mpool.h"
#include "splay-tree.h"
#include "options.h"
#include "color.h"

int bgcr = 0xff;
int bgcg = 0xff;
int bgcb = 0xff;

/* memory for the color data */
static struct mpool *color_pool = NULL;

static splay_tree gucolor = NULL;

/* The type of a function used to allocate memory for tree root and
   node structures.  The first argument is the number of bytes needed;
   the second is a data pointer the splay tree functions pass through
   to the allocator.  This function must never return zero.  */
static void *ucolor_splay_tree_allocate_fn (size_t n, void *data);

/* The type of a function used to free memory allocated using the
   corresponding splay_tree_allocate_fn.  The first argument is the
   memory to be freed; the latter is a data pointer the splay tree
   functions pass through to the freer.  */
static void ucolor_splay_tree_deallocate_fn (void *pointer, void *data);

/* The type of a function used to deallocate any resources associated
   with the key.  */
static void ucolor_splay_tree_delete_key_fn (splay_tree_key keydata);

/* The type of a function used to deallocate any resources associated
   with the value.  */
static void ucolor_splay_tree_delete_value_fn (splay_tree_value valuedata);

static void coloradd (const char *name, int code);

static void ilona (void);

void
color_init (void)
{

  /* fresh memory */
  mpool_pool_delete (color_pool);
  color_pool = mpool_pool_new ();

  /* indexed on (char *) */
  gucolor = splay_tree_new_with_allocator (splay_tree_compare_strings,	/* splay_tree_compare_fn */
					   ucolor_splay_tree_delete_key_fn,	/* splay_tree_delete_key_fn */
					   ucolor_splay_tree_delete_value_fn,	/* splay_tree_delete_value_fn */
					   ucolor_splay_tree_allocate_fn,	/* splay_tree_allocate_fn */
					   ucolor_splay_tree_deallocate_fn,	/* splay_tree_deallocate_fn */
					   (void *) 0	/* allocate-data */
    );

  coloradd ("snow", 0x00fffafa);
  coloradd ("ghostwhite", 0x00f8f8ff);
  coloradd ("ghost white", 0x00f8f8ff);
  coloradd ("GhostWhite", 0x00f8f8ff);
  coloradd ("whitesmoke", 0x00f5f5f5);
  coloradd ("white smoke", 0x00f5f5f5);
  coloradd ("WhiteSmoke", 0x00f5f5f5);
  coloradd ("gainsboro", 0x00dcdcdc);
  coloradd ("floralwhite", 0x00fffaf0);
  coloradd ("floral white", 0x00fffaf0);
  coloradd ("FloralWhite", 0x00fffaf0);
  coloradd ("oldlace", 0x00fdf5e6);
  coloradd ("old lace", 0x00fdf5e6);
  coloradd ("OldLace", 0x00fdf5e6);
  coloradd ("linen", 0x00faf0e6);
  coloradd ("antiquewhite", 0x00faebd7);
  coloradd ("antique white", 0x00faebd7);
  coloradd ("AntiqueWhite", 0x00faebd7);
  coloradd ("papayawhip", 0x00ffefd5);
  coloradd ("papaya whip", 0x00ffefd5);
  coloradd ("PapayaWhip", 0x00ffefd5);
  coloradd ("blanchedalmond", 0x00ffebcd);
  coloradd ("blanched almond", 0x00ffebcd);
  coloradd ("BlanchedAlmond", 0x00ffebcd);
  coloradd ("bisque", 0x00ffe4c4);
  coloradd ("peachpuff", 0x00ffdab9);
  coloradd ("peach puff", 0x00ffdab9);
  coloradd ("PeachPuff", 0x00ffdab9);
  coloradd ("navajowhite", 0x00ffdead);
  coloradd ("navajo white", 0x00ffdead);
  coloradd ("NavajoWhite", 0x00ffdead);
  coloradd ("moccasin", 0x00ffe4b5);
  coloradd ("cornsilk", 0x00fff8dc);
  coloradd ("ivory", 0x00fffff0);
  coloradd ("lemonchiffon", 0x00fffacd);
  coloradd ("lemon chiffon", 0x00fffacd);
  coloradd ("LemonChiffon", 0x00fffacd);
  coloradd ("seashell", 0x00fff5ee);
  coloradd ("honeydew", 0x00f0fff0);
  coloradd ("mintcream", 0x00f5fffa);
  coloradd ("mint cream", 0x00f5fffa);
  coloradd ("MintCream", 0x00f5fffa);
  coloradd ("azure", 0x00f0ffff);
  coloradd ("aliceblue", 0x00f0f8ff);
  coloradd ("alice blue", 0x00f0f8ff);
  coloradd ("AliceBlue", 0x00f0f8ff);
  coloradd ("lavender", 0x00e6e6fa);
  coloradd ("lavenderblush", 0x00fff0f5);
  coloradd ("lavender blush", 0x00fff0f5);
  coloradd ("LavenderBlush", 0x00fff0f5);
  coloradd ("mistyrose", 0x00ffe4e1);
  coloradd ("misty rose", 0x00ffe4e1);
  coloradd ("MistyRose", 0x00ffe4e1);
  coloradd ("white", 0x00ffffff);
  coloradd ("black", 0x00000000);
  coloradd ("darkslategray", 0x002f4f4f);
  coloradd ("dark slate gray", 0x002f4f4f);
  coloradd ("DarkSlateGray", 0x002f4f4f);
  coloradd ("darkslategrey", 0x002f4f4f);
  coloradd ("dark slate grey", 0x002f4f4f);
  coloradd ("DarkSlateGrey", 0x002f4f4f);
  coloradd ("dimgray", 0x00696969);
  coloradd ("dim gray", 0x00696969);
  coloradd ("DimGray", 0x00696969);
  coloradd ("dimgrey", 0x00696969);
  coloradd ("dim grey", 0x00696969);
  coloradd ("DimGrey", 0x00696969);
  coloradd ("slategray", 0x00708090);
  coloradd ("slate gray", 0x00708090);
  coloradd ("SlateGray", 0x00708090);
  coloradd ("slategrey", 0x00708090);
  coloradd ("slate grey", 0x00708090);
  coloradd ("SlateGrey", 0x00708090);
  coloradd ("lightslategray", 0x00778899);
  coloradd ("light slate gray", 0x00778899);
  coloradd ("LightSlateGray", 0x00778899);
  coloradd ("lightslategrey", 0x00778899);
  coloradd ("light slate grey", 0x00778899);
  coloradd ("LightSlateGrey", 0x00778899);
  coloradd ("gray", 0x00bebebe);
  coloradd ("grey", 0x00bebebe);
  coloradd ("lightgrey", 0x00d3d3d3);
  coloradd ("light grey", 0x00d3d3d3);
  coloradd ("LightGrey", 0x00d3d3d3);
  coloradd ("lightgray", 0x00d3d3d3);
  coloradd ("light gray", 0x00d3d3d3);
  coloradd ("LightGray", 0x00d3d3d3);
  coloradd ("midnightblue", 0x00191970);
  coloradd ("midnight blue", 0x00191970);
  coloradd ("MidnightBlue", 0x00191970);
  coloradd ("navy", 0x00000080);
  coloradd ("navyblue", 0x00000080);
  coloradd ("navy blue", 0x00000080);
  coloradd ("NavyBlue", 0x00000080);
  coloradd ("cornflowerblue", 0x006495ed);
  coloradd ("cornflower blue", 0x006495ed);
  coloradd ("CornflowerBlue", 0x006495ed);
  coloradd ("darkslateblue", 0x00483d8b);
  coloradd ("dark slate blue", 0x00483d8b);
  coloradd ("DarkSlateBlue", 0x00483d8b);
  coloradd ("slateblue", 0x006a5acd);
  coloradd ("slate blue", 0x006a5acd);
  coloradd ("SlateBlue", 0x006a5acd);
  coloradd ("mediumslateblue", 0x007b68ee);
  coloradd ("medium slate blue", 0x007b68ee);
  coloradd ("MediumSlateBlue", 0x007b68ee);
  coloradd ("lightslateblue", 0x008470ff);
  coloradd ("light slate blue", 0x008470ff);
  coloradd ("LightSlateBlue", 0x008470ff);
  coloradd ("mediumblue", 0x000000cd);
  coloradd ("medium blue", 0x000000cd);
  coloradd ("MediumBlue", 0x000000cd);
  coloradd ("royalblue", 0x004169e1);
  coloradd ("royal blue", 0x004169e1);
  coloradd ("RoyalBlue", 0x004169e1);
  coloradd ("blue", 0x000000ff);
  coloradd ("dodgerblue", 0x001e90ff);
  coloradd ("dodger blue", 0x001e90ff);
  coloradd ("DodgerBlue", 0x001e90ff);
  coloradd ("deepskyblue", 0x0000bfff);
  coloradd ("deep sky blue", 0x0000bfff);
  coloradd ("DeepSkyBlue", 0x0000bfff);
  coloradd ("skyblue", 0x0087ceeb);
  coloradd ("sky blue", 0x0087ceeb);
  coloradd ("SkyBlue", 0x0087ceeb);
  coloradd ("lightskyblue", 0x0087cefa);
  coloradd ("light sky blue", 0x0087cefa);
  coloradd ("LightSkyBlue", 0x0087cefa);
  coloradd ("steelblue", 0x004682b4);
  coloradd ("steel blue", 0x004682b4);
  coloradd ("SteelBlue", 0x004682b4);
  coloradd ("lightsteelblue", 0x00b0c4de);
  coloradd ("light steel blue", 0x00b0c4de);
  coloradd ("LightSteelBlue", 0x00b0c4de);
  coloradd ("lightblue", 0x00add8e6);
  coloradd ("light blue", 0x00add8e6);
  coloradd ("LightBlue", 0x00add8e6);
  coloradd ("powderblue", 0x00b0e0e6);
  coloradd ("powder blue", 0x00b0e0e6);
  coloradd ("PowderBlue", 0x00b0e0e6);
  coloradd ("paleturquoise", 0x00afeeee);
  coloradd ("pale turquoise", 0x00afeeee);
  coloradd ("PaleTurquoise", 0x00afeeee);
  coloradd ("darkturquoise", 0x0000ced1);
  coloradd ("dark turquoise", 0x0000ced1);
  coloradd ("DarkTurquoise", 0x0000ced1);
  coloradd ("mediumturquoise", 0x0048d1cc);
  coloradd ("medium turquoise", 0x0048d1cc);
  coloradd ("MediumTurquoise", 0x0048d1cc);
  coloradd ("turquoise", 0x0040e0d0);
  coloradd ("cyan", 0x0000ffff);
  coloradd ("lightcyan", 0x00e0ffff);
  coloradd ("light cyan", 0x00e0ffff);
  coloradd ("LightCyan", 0x00e0ffff);
  coloradd ("cadetblue", 0x005f9ea0);
  coloradd ("cadet blue", 0x005f9ea0);
  coloradd ("CadetBlue", 0x005f9ea0);
  coloradd ("mediumaquamarine", 0x0066cdaa);
  coloradd ("medium aquamarine", 0x0066cdaa);
  coloradd ("MediumAquamarine", 0x0066cdaa);
  coloradd ("aquamarine", 0x007fffd4);
  coloradd ("darkgreen", 0x00006400);
  coloradd ("dark green", 0x00006400);
  coloradd ("DarkGreen", 0x00006400);
  coloradd ("darkolivegreen", 0x00556b2f);
  coloradd ("dark olive green", 0x00556b2f);
  coloradd ("DarkOliveGreen", 0x00556b2f);
  coloradd ("darkseagreen", 0x008fbc8f);
  coloradd ("dark sea green", 0x008fbc8f);
  coloradd ("DarkSeaGreen", 0x008fbc8f);
  coloradd ("seagreen", 0x002e8b57);
  coloradd ("sea green", 0x002e8b57);
  coloradd ("SeaGreen", 0x002e8b57);
  coloradd ("mediumseagreen", 0x003cb371);
  coloradd ("medium sea green", 0x003cb371);
  coloradd ("MediumSeaGreen", 0x003cb371);
  coloradd ("lightseagreen", 0x0020b2aa);
  coloradd ("light sea green", 0x0020b2aa);
  coloradd ("LightSeaGreen", 0x0020b2aa);
  coloradd ("palegreen", 0x0098fb98);
  coloradd ("pale green", 0x0098fb98);
  coloradd ("PaleGreen", 0x0098fb98);
  coloradd ("springgreen", 0x0000ff7f);
  coloradd ("spring green", 0x0000ff7f);
  coloradd ("SpringGreen", 0x0000ff7f);
  coloradd ("lawngreen", 0x007cfc00);
  coloradd ("lawn green", 0x007cfc00);
  coloradd ("LawnGreen", 0x007cfc00);
  coloradd ("green", 0x0000ff00);
  coloradd ("chartreuse", 0x007fff00);
  coloradd ("mediumspringgreen", 0x0000fa9a);
  coloradd ("medium spring green", 0x0000fa9a);
  coloradd ("MediumSpringGreen", 0x0000fa9a);
  coloradd ("greenyellow", 0x00adff2f);
  coloradd ("green yellow", 0x00adff2f);
  coloradd ("GreenYellow", 0x00adff2f);
  coloradd ("limegreen", 0x0032cd32);
  coloradd ("lime green", 0x0032cd32);
  coloradd ("LimeGreen", 0x0032cd32);
  coloradd ("yellowgreen", 0x009acd32);
  coloradd ("yellow green", 0x009acd32);
  coloradd ("YellowGreen", 0x009acd32);
  coloradd ("forestgreen", 0x00228b22);
  coloradd ("forest green", 0x00228b22);
  coloradd ("ForestGreen", 0x00228b22);
  coloradd ("olivedrab", 0x006b8e23);
  coloradd ("olive drab", 0x006b8e23);
  coloradd ("OliveDrab", 0x006b8e23);
  coloradd ("darkkhaki", 0x00bdb76b);
  coloradd ("dark khaki", 0x00bdb76b);
  coloradd ("DarkKhaki", 0x00bdb76b);
  coloradd ("khaki", 0x00f0e68c);
  coloradd ("palegoldenrod", 0x00eee8aa);
  coloradd ("pale goldenrod", 0x00eee8aa);
  coloradd ("PaleGoldenrod", 0x00eee8aa);
  coloradd ("lightgoldenrodyellow", 0x00fafad2);
  coloradd ("light goldenrod yellow", 0x00fafad2);
  coloradd ("LightGoldenrodYellow", 0x00fafad2);
  coloradd ("lightyellow", 0x00ffffe0);
  coloradd ("light yellow", 0x00ffffe0);
  coloradd ("LightYellow", 0x00ffffe0);
  coloradd ("yellow", 0x00ffff00);
  coloradd ("gold", 0x00ffd700);
  coloradd ("lightgoldenrod", 0x00eedd82);
  coloradd ("light goldenrod", 0x00eedd82);
  coloradd ("LightGoldenrod", 0x00eedd82);
  coloradd ("goldenrod", 0x00daa520);
  coloradd ("darkgoldenrod", 0x00b8860b);
  coloradd ("dark goldenrod", 0x00b8860b);
  coloradd ("DarkGoldenrod", 0x00b8860b);
  coloradd ("rosybrown", 0x00bc8f8f);
  coloradd ("rosy brown", 0x00bc8f8f);
  coloradd ("RosyBrown", 0x00bc8f8f);
  coloradd ("indianred", 0x00cd5c5c);
  coloradd ("indian red", 0x00cd5c5c);
  coloradd ("IndianRed", 0x00cd5c5c);
  coloradd ("saddlebrown", 0x008b4513);
  coloradd ("saddle brown", 0x008b4513);
  coloradd ("SaddleBrown", 0x008b4513);
  coloradd ("sienna", 0x00a0522d);
  coloradd ("peru", 0x00cd853f);
  coloradd ("burlywood", 0x00deb887);
  coloradd ("beige", 0x00f5f5dc);
  coloradd ("wheat", 0x00f5deb3);
  coloradd ("sandybrown", 0x00f4a460);
  coloradd ("sandy brown", 0x00f4a460);
  coloradd ("SandyBrown", 0x00f4a460);
  coloradd ("tan", 0x00d2b48c);
  coloradd ("chocolate", 0x00d2691e);
  coloradd ("firebrick", 0x00b22222);
  coloradd ("brown", 0x00a52a2a);
  coloradd ("darksalmon", 0x00e9967a);
  coloradd ("dark salmon", 0x00e9967a);
  coloradd ("DarkSalmon", 0x00e9967a);
  coloradd ("salmon", 0x00fa8072);
  coloradd ("lightsalmon", 0x00ffa07a);
  coloradd ("light salmon", 0x00ffa07a);
  coloradd ("LightSalmon", 0x00ffa07a);
  coloradd ("orange", 0x00ffa500);
  coloradd ("darkorange", 0x00ff8c00);
  coloradd ("dark orange", 0x00ff8c00);
  coloradd ("DarkOrange", 0x00ff8c00);
  coloradd ("coral", 0x00ff7f50);
  coloradd ("lightcoral", 0x00f08080);
  coloradd ("light coral", 0x00f08080);
  coloradd ("LightCoral", 0x00f08080);
  coloradd ("tomato", 0x00ff6347);
  coloradd ("orangered", 0x00ff4500);
  coloradd ("orange red", 0x00ff4500);
  coloradd ("OrangeRed", 0x00ff4500);
  coloradd ("red", 0x00ff0000);
  coloradd ("hotpink", 0x00ff69b4);
  coloradd ("hot pink", 0x00ff69b4);
  coloradd ("HotPink", 0x00ff69b4);
  coloradd ("deeppink", 0x00ff1493);
  coloradd ("deep pink", 0x00ff1493);
  coloradd ("DeepPink", 0x00ff1493);
  coloradd ("pink", 0x00ffc0cb);
  coloradd ("lightpink", 0x00ffb6c1);
  coloradd ("light pink", 0x00ffb6c1);
  coloradd ("LightPink", 0x00ffb6c1);
  coloradd ("palevioletred", 0x00db7093);
  coloradd ("pale violet red", 0x00db7093);
  coloradd ("PaleVioletRed", 0x00db7093);
  coloradd ("maroon", 0x00b03060);
  coloradd ("mediumvioletred", 0x00c71585);
  coloradd ("medium violet red", 0x00c71585);
  coloradd ("MediumVioletRed", 0x00c71585);
  coloradd ("violetred", 0x00d02090);
  coloradd ("violet red", 0x00d02090);
  coloradd ("VioletRed", 0x00d02090);
  coloradd ("magenta", 0x00ff00ff);
  coloradd ("violet", 0x00ee82ee);
  coloradd ("plum", 0x00dda0dd);
  coloradd ("orchid", 0x00da70d6);
  coloradd ("mediumorchid", 0x00ba55d3);
  coloradd ("medium orchid", 0x00ba55d3);
  coloradd ("MediumOrchid", 0x00ba55d3);
  coloradd ("darkorchid", 0x009932cc);
  coloradd ("dark orchid", 0x009932cc);
  coloradd ("DarkOrchid", 0x009932cc);
  coloradd ("darkviolet", 0x009400d3);
  coloradd ("dark violet", 0x009400d3);
  coloradd ("DarkViolet", 0x009400d3);
  coloradd ("blueviolet", 0x008a2be2);
  coloradd ("blue violet", 0x008a2be2);
  coloradd ("BlueViolet", 0x008a2be2);
  coloradd ("purple", 0x00a020f0);
  coloradd ("mediumpurple", 0x009370db);
  coloradd ("medium purple", 0x009370db);
  coloradd ("MediumPurple", 0x009370db);
  coloradd ("thistle", 0x00d8bfd8);
  coloradd ("snow1", 0x00fffafa);
  coloradd ("snow2", 0x00eee9e9);
  coloradd ("snow3", 0x00cdc9c9);
  coloradd ("snow4", 0x008b8989);
  coloradd ("seashell1", 0x00fff5ee);
  coloradd ("seashell2", 0x00eee5de);
  coloradd ("seashell3", 0x00cdc5bf);
  coloradd ("seashell4", 0x008b8682);
  coloradd ("AntiqueWhite1", 0x00ffefdb);
  coloradd ("AntiqueWhite2", 0x00eedfcc);
  coloradd ("AntiqueWhite3", 0x00cdc0b0);
  coloradd ("AntiqueWhite4", 0x008b8378);
  coloradd ("bisque1", 0x00ffe4c4);
  coloradd ("bisque2", 0x00eed5b7);
  coloradd ("bisque3", 0x00cdb79e);
  coloradd ("bisque4", 0x008b7d6b);
  coloradd ("PeachPuff1", 0x00ffdab9);
  coloradd ("PeachPuff2", 0x00eecbad);
  coloradd ("PeachPuff3", 0x00cdaf95);
  coloradd ("PeachPuff4", 0x008b7765);
  coloradd ("NavajoWhite1", 0x00ffdead);
  coloradd ("NavajoWhite2", 0x00eecfa1);
  coloradd ("NavajoWhite3", 0x00cdb38b);
  coloradd ("NavajoWhite4", 0x008b795e);
  coloradd ("LemonChiffon1", 0x00fffacd);
  coloradd ("LemonChiffon2", 0x00eee9bf);
  coloradd ("LemonChiffon3", 0x00cdc9a5);
  coloradd ("LemonChiffon4", 0x008b8970);
  coloradd ("cornsilk1", 0x00fff8dc);
  coloradd ("cornsilk2", 0x00eee8cd);
  coloradd ("cornsilk3", 0x00cdc8b1);
  coloradd ("cornsilk4", 0x008b8878);
  coloradd ("ivory1", 0x00fffff0);
  coloradd ("ivory2", 0x00eeeee0);
  coloradd ("ivory3", 0x00cdcdc1);
  coloradd ("ivory4", 0x008b8b83);
  coloradd ("honeydew1", 0x00f0fff0);
  coloradd ("honeydew2", 0x00e0eee0);
  coloradd ("honeydew3", 0x00c1cdc1);
  coloradd ("honeydew4", 0x00838b83);
  coloradd ("LavenderBlush1", 0x00fff0f5);
  coloradd ("LavenderBlush2", 0x00eee0e5);
  coloradd ("LavenderBlush3", 0x00cdc1c5);
  coloradd ("LavenderBlush4", 0x008b8386);
  coloradd ("MistyRose1", 0x00ffe4e1);
  coloradd ("MistyRose2", 0x00eed5d2);
  coloradd ("MistyRose3", 0x00cdb7b5);
  coloradd ("MistyRose4", 0x008b7d7b);
  coloradd ("azure1", 0x00f0ffff);
  coloradd ("azure2", 0x00e0eeee);
  coloradd ("azure3", 0x00c1cdcd);
  coloradd ("azure4", 0x00838b8b);
  coloradd ("SlateBlue1", 0x00836fff);
  coloradd ("SlateBlue2", 0x007a67ee);
  coloradd ("SlateBlue3", 0x006959cd);
  coloradd ("SlateBlue4", 0x00473c8b);
  coloradd ("RoyalBlue1", 0x004876ff);
  coloradd ("RoyalBlue2", 0x00436eee);
  coloradd ("RoyalBlue3", 0x003a5fcd);
  coloradd ("RoyalBlue4", 0x0027408b);
  coloradd ("blue1", 0x000000ff);
  coloradd ("blue2", 0x000000ee);
  coloradd ("blue3", 0x000000cd);
  coloradd ("blue4", 0x0000008b);
  coloradd ("DodgerBlue1", 0x001e90ff);
  coloradd ("DodgerBlue2", 0x001c86ee);
  coloradd ("DodgerBlue3", 0x001874cd);
  coloradd ("DodgerBlue4", 0x00104e8b);
  coloradd ("SteelBlue1", 0x0063b8ff);
  coloradd ("SteelBlue2", 0x005cacee);
  coloradd ("SteelBlue3", 0x004f94cd);
  coloradd ("SteelBlue4", 0x0036648b);
  coloradd ("DeepSkyBlue1", 0x0000bfff);
  coloradd ("DeepSkyBlue2", 0x0000b2ee);
  coloradd ("DeepSkyBlue3", 0x00009acd);
  coloradd ("DeepSkyBlue4", 0x0000688b);
  coloradd ("SkyBlue1", 0x0087ceff);
  coloradd ("SkyBlue2", 0x007ec0ee);
  coloradd ("SkyBlue3", 0x006ca6cd);
  coloradd ("SkyBlue4", 0x004a708b);
  coloradd ("LightSkyBlue1", 0x00b0e2ff);
  coloradd ("LightSkyBlue2", 0x00a4d3ee);
  coloradd ("LightSkyBlue3", 0x008db6cd);
  coloradd ("LightSkyBlue4", 0x00607b8b);
  coloradd ("SlateGray1", 0x00c6e2ff);
  coloradd ("SlateGray2", 0x00b9d3ee);
  coloradd ("SlateGray3", 0x009fb6cd);
  coloradd ("SlateGray4", 0x006c7b8b);
  coloradd ("LightSteelBlue1", 0x00cae1ff);
  coloradd ("LightSteelBlue2", 0x00bcd2ee);
  coloradd ("LightSteelBlue3", 0x00a2b5cd);
  coloradd ("LightSteelBlue4", 0x006e7b8b);
  coloradd ("LightBlue1", 0x00bfefff);
  coloradd ("LightBlue2", 0x00b2dfee);
  coloradd ("LightBlue3", 0x009ac0cd);
  coloradd ("LightBlue4", 0x0068838b);
  coloradd ("LightCyan1", 0x00e0ffff);
  coloradd ("LightCyan2", 0x00d1eeee);
  coloradd ("LightCyan3", 0x00b4cdcd);
  coloradd ("LightCyan4", 0x007a8b8b);
  coloradd ("PaleTurquoise1", 0x00bbffff);
  coloradd ("PaleTurquoise2", 0x00aeeeee);
  coloradd ("PaleTurquoise3", 0x0096cdcd);
  coloradd ("PaleTurquoise4", 0x00668b8b);
  coloradd ("CadetBlue1", 0x0098f5ff);
  coloradd ("CadetBlue2", 0x008ee5ee);
  coloradd ("CadetBlue3", 0x007ac5cd);
  coloradd ("CadetBlue4", 0x0053868b);
  coloradd ("turquoise1", 0x0000f5ff);
  coloradd ("turquoise2", 0x0000e5ee);
  coloradd ("turquoise3", 0x0000c5cd);
  coloradd ("turquoise4", 0x0000868b);
  coloradd ("cyan1", 0x0000ffff);
  coloradd ("cyan2", 0x0000eeee);
  coloradd ("cyan3", 0x0000cdcd);
  coloradd ("cyan4", 0x00008b8b);
  coloradd ("DarkSlateGray1", 0x0097ffff);
  coloradd ("DarkSlateGray2", 0x008deeee);
  coloradd ("DarkSlateGray3", 0x0079cdcd);
  coloradd ("DarkSlateGray4", 0x00528b8b);
  coloradd ("aquamarine1", 0x007fffd4);
  coloradd ("aquamarine2", 0x0076eec6);
  coloradd ("aquamarine3", 0x0066cdaa);
  coloradd ("aquamarine4", 0x00458b74);
  coloradd ("DarkSeaGreen1", 0x00c1ffc1);
  coloradd ("DarkSeaGreen2", 0x00b4eeb4);
  coloradd ("DarkSeaGreen3", 0x009bcd9b);
  coloradd ("DarkSeaGreen4", 0x00698b69);
  coloradd ("SeaGreen1", 0x0054ff9f);
  coloradd ("SeaGreen2", 0x004eee94);
  coloradd ("SeaGreen3", 0x0043cd80);
  coloradd ("SeaGreen4", 0x002e8b57);
  coloradd ("PaleGreen1", 0x009aff9a);
  coloradd ("PaleGreen2", 0x0090ee90);
  coloradd ("PaleGreen3", 0x007ccd7c);
  coloradd ("PaleGreen4", 0x00548b54);
  coloradd ("SpringGreen1", 0x0000ff7f);
  coloradd ("SpringGreen2", 0x0000ee76);
  coloradd ("SpringGreen3", 0x0000cd66);
  coloradd ("SpringGreen4", 0x00008b45);
  coloradd ("green1", 0x0000ff00);
  coloradd ("green2", 0x0000ee00);
  coloradd ("green3", 0x0000cd00);
  coloradd ("green4", 0x00008b00);
  coloradd ("chartreuse1", 0x007fff00);
  coloradd ("chartreuse2", 0x0076ee00);
  coloradd ("chartreuse3", 0x0066cd00);
  coloradd ("chartreuse4", 0x00458b00);
  coloradd ("OliveDrab1", 0x00c0ff3e);
  coloradd ("OliveDrab2", 0x00b3ee3a);
  coloradd ("OliveDrab3", 0x009acd32);
  coloradd ("OliveDrab4", 0x00698b22);
  coloradd ("DarkOliveGreen1", 0x00caff70);
  coloradd ("DarkOliveGreen2", 0x00bcee68);
  coloradd ("DarkOliveGreen3", 0x00a2cd5a);
  coloradd ("DarkOliveGreen4", 0x006e8b3d);
  coloradd ("khaki1", 0x00fff68f);
  coloradd ("khaki2", 0x00eee685);
  coloradd ("khaki3", 0x00cdc673);
  coloradd ("khaki4", 0x008b864e);
  coloradd ("LightGoldenrod1", 0x00ffec8b);
  coloradd ("LightGoldenrod2", 0x00eedc82);
  coloradd ("LightGoldenrod3", 0x00cdbe70);
  coloradd ("LightGoldenrod4", 0x008b814c);
  coloradd ("LightYellow1", 0x00ffffe0);
  coloradd ("LightYellow2", 0x00eeeed1);
  coloradd ("LightYellow3", 0x00cdcdb4);
  coloradd ("LightYellow4", 0x008b8b7a);
  coloradd ("yellow1", 0x00ffff00);
  coloradd ("yellow2", 0x00eeee00);
  coloradd ("yellow3", 0x00cdcd00);
  coloradd ("yellow4", 0x008b8b00);
  coloradd ("gold1", 0x00ffd700);
  coloradd ("gold2", 0x00eec900);
  coloradd ("gold3", 0x00cdad00);
  coloradd ("gold4", 0x008b7500);
  coloradd ("goldenrod1", 0x00ffc125);
  coloradd ("goldenrod2", 0x00eeb422);
  coloradd ("goldenrod3", 0x00cd9b1d);
  coloradd ("goldenrod4", 0x008b6914);
  coloradd ("DarkGoldenrod1", 0x00ffb90f);
  coloradd ("DarkGoldenrod2", 0x00eead0e);
  coloradd ("DarkGoldenrod3", 0x00cd950c);
  coloradd ("DarkGoldenrod4", 0x008b6508);
  coloradd ("RosyBrown1", 0x00ffc1c1);
  coloradd ("RosyBrown2", 0x00eeb4b4);
  coloradd ("RosyBrown3", 0x00cd9b9b);
  coloradd ("RosyBrown4", 0x008b6969);
  coloradd ("IndianRed1", 0x00ff6a6a);
  coloradd ("IndianRed2", 0x00ee6363);
  coloradd ("IndianRed3", 0x00cd5555);
  coloradd ("IndianRed4", 0x008b3a3a);
  coloradd ("sienna1", 0x00ff8247);
  coloradd ("sienna2", 0x00ee7942);
  coloradd ("sienna3", 0x00cd6839);
  coloradd ("sienna4", 0x008b4726);
  coloradd ("burlywood1", 0x00ffd39b);
  coloradd ("burlywood2", 0x00eec591);
  coloradd ("burlywood3", 0x00cdaa7d);
  coloradd ("burlywood4", 0x008b7355);
  coloradd ("wheat1", 0x00ffe7ba);
  coloradd ("wheat2", 0x00eed8ae);
  coloradd ("wheat3", 0x00cdba96);
  coloradd ("wheat4", 0x008b7e66);
  coloradd ("tan1", 0x00ffa54f);
  coloradd ("tan2", 0x00ee9a49);
  coloradd ("tan3", 0x00cd853f);
  coloradd ("tan4", 0x008b5a2b);
  coloradd ("chocolate1", 0x00ff7f24);
  coloradd ("chocolate2", 0x00ee7621);
  coloradd ("chocolate3", 0x00cd661d);
  coloradd ("chocolate4", 0x008b4513);
  coloradd ("firebrick1", 0x00ff3030);
  coloradd ("firebrick2", 0x00ee2c2c);
  coloradd ("firebrick3", 0x00cd2626);
  coloradd ("firebrick4", 0x008b1a1a);
  coloradd ("brown1", 0x00ff4040);
  coloradd ("brown2", 0x00ee3b3b);
  coloradd ("brown3", 0x00cd3333);
  coloradd ("brown4", 0x008b2323);
  coloradd ("salmon1", 0x00ff8c69);
  coloradd ("salmon2", 0x00ee8262);
  coloradd ("salmon3", 0x00cd7054);
  coloradd ("salmon4", 0x008b4c39);
  coloradd ("LightSalmon1", 0x00ffa07a);
  coloradd ("LightSalmon2", 0x00ee9572);
  coloradd ("LightSalmon3", 0x00cd8162);
  coloradd ("LightSalmon4", 0x008b5742);
  coloradd ("orange1", 0x00ffa500);
  coloradd ("orange2", 0x00ee9a00);
  coloradd ("orange3", 0x00cd8500);
  coloradd ("orange4", 0x008b5a00);
  coloradd ("DarkOrange1", 0x00ff7f00);
  coloradd ("DarkOrange2", 0x00ee7600);
  coloradd ("DarkOrange3", 0x00cd6600);
  coloradd ("DarkOrange4", 0x008b4500);
  coloradd ("coral1", 0x00ff7256);
  coloradd ("coral2", 0x00ee6a50);
  coloradd ("coral3", 0x00cd5b45);
  coloradd ("coral4", 0x008b3e2f);
  coloradd ("tomato1", 0x00ff6347);
  coloradd ("tomato2", 0x00ee5c42);
  coloradd ("tomato3", 0x00cd4f39);
  coloradd ("tomato4", 0x008b3626);
  coloradd ("OrangeRed1", 0x00ff4500);
  coloradd ("OrangeRed2", 0x00ee4000);
  coloradd ("OrangeRed3", 0x00cd3700);
  coloradd ("OrangeRed4", 0x008b2500);
  coloradd ("red1", 0x00ff0000);
  coloradd ("red2", 0x00ee0000);
  coloradd ("red3", 0x00cd0000);
  coloradd ("red4", 0x008b0000);
  coloradd ("DebianRed", 0x00d70751);
  coloradd ("DeepPink1", 0x00ff1493);
  coloradd ("DeepPink2", 0x00ee1289);
  coloradd ("DeepPink3", 0x00cd1076);
  coloradd ("DeepPink4", 0x008b0a50);
  coloradd ("HotPink1", 0x00ff6eb4);
  coloradd ("HotPink2", 0x00ee6aa7);
  coloradd ("HotPink3", 0x00cd6090);
  coloradd ("HotPink4", 0x008b3a62);
  coloradd ("pink1", 0x00ffb5c5);
  coloradd ("pink2", 0x00eea9b8);
  coloradd ("pink3", 0x00cd919e);
  coloradd ("pink4", 0x008b636c);
  coloradd ("LightPink1", 0x00ffaeb9);
  coloradd ("LightPink2", 0x00eea2ad);
  coloradd ("LightPink3", 0x00cd8c95);
  coloradd ("LightPink4", 0x008b5f65);
  coloradd ("PaleVioletRed1", 0x00ff82ab);
  coloradd ("PaleVioletRed2", 0x00ee799f);
  coloradd ("PaleVioletRed3", 0x00cd6889);
  coloradd ("PaleVioletRed4", 0x008b475d);
  coloradd ("maroon1", 0x00ff34b3);
  coloradd ("maroon2", 0x00ee30a7);
  coloradd ("maroon3", 0x00cd2990);
  coloradd ("maroon4", 0x008b1c62);
  coloradd ("VioletRed1", 0x00ff3e96);
  coloradd ("VioletRed2", 0x00ee3a8c);
  coloradd ("VioletRed3", 0x00cd3278);
  coloradd ("VioletRed4", 0x008b2252);
  coloradd ("magenta1", 0x00ff00ff);
  coloradd ("magenta2", 0x00ee00ee);
  coloradd ("magenta3", 0x00cd00cd);
  coloradd ("magenta4", 0x008b008b);
  coloradd ("orchid1", 0x00ff83fa);
  coloradd ("orchid2", 0x00ee7ae9);
  coloradd ("orchid3", 0x00cd69c9);
  coloradd ("orchid4", 0x008b4789);
  coloradd ("plum1", 0x00ffbbff);
  coloradd ("plum2", 0x00eeaeee);
  coloradd ("plum3", 0x00cd96cd);
  coloradd ("plum4", 0x008b668b);
  coloradd ("MediumOrchid1", 0x00e066ff);
  coloradd ("MediumOrchid2", 0x00d15fee);
  coloradd ("MediumOrchid3", 0x00b452cd);
  coloradd ("MediumOrchid4", 0x007a378b);
  coloradd ("DarkOrchid1", 0x00bf3eff);
  coloradd ("DarkOrchid2", 0x00b23aee);
  coloradd ("DarkOrchid3", 0x009a32cd);
  coloradd ("DarkOrchid4", 0x0068228b);
  coloradd ("purple1", 0x009b30ff);
  coloradd ("purple2", 0x00912cee);
  coloradd ("purple3", 0x007d26cd);
  coloradd ("purple4", 0x00551a8b);
  coloradd ("MediumPurple1", 0x00ab82ff);
  coloradd ("MediumPurple2", 0x009f79ee);
  coloradd ("MediumPurple3", 0x008968cd);
  coloradd ("MediumPurple4", 0x005d478b);
  coloradd ("thistle1", 0x00ffe1ff);
  coloradd ("thistle2", 0x00eed2ee);
  coloradd ("thistle3", 0x00cdb5cd);
  coloradd ("thistle4", 0x008b7b8b);
  coloradd ("gray0", 0x00000000);
  coloradd ("grey0", 0x00000000);
  coloradd ("gray1", 0x00030303);
  coloradd ("grey1", 0x00030303);
  coloradd ("gray2", 0x00050505);
  coloradd ("grey2", 0x00050505);
  coloradd ("gray3", 0x00080808);
  coloradd ("grey3", 0x00080808);
  coloradd ("gray4", 0x000a0a0a);
  coloradd ("grey4", 0x000a0a0a);
  coloradd ("gray5", 0x000d0d0d);
  coloradd ("grey5", 0x000d0d0d);
  coloradd ("gray6", 0x000f0f0f);
  coloradd ("grey6", 0x000f0f0f);
  coloradd ("gray7", 0x00121212);
  coloradd ("grey7", 0x00121212);
  coloradd ("gray8", 0x00141414);
  coloradd ("grey8", 0x00141414);
  coloradd ("gray9", 0x00171717);
  coloradd ("grey9", 0x00171717);
  coloradd ("gray10", 0x001a1a1a);
  coloradd ("grey10", 0x001a1a1a);
  coloradd ("gray11", 0x001c1c1c);
  coloradd ("grey11", 0x001c1c1c);
  coloradd ("gray12", 0x001f1f1f);
  coloradd ("grey12", 0x001f1f1f);
  coloradd ("gray13", 0x00212121);
  coloradd ("grey13", 0x00212121);
  coloradd ("gray14", 0x00242424);
  coloradd ("grey14", 0x00242424);
  coloradd ("gray15", 0x00262626);
  coloradd ("grey15", 0x00262626);
  coloradd ("gray16", 0x00292929);
  coloradd ("grey16", 0x00292929);
  coloradd ("gray17", 0x002b2b2b);
  coloradd ("grey17", 0x002b2b2b);
  coloradd ("gray18", 0x002e2e2e);
  coloradd ("grey18", 0x002e2e2e);
  coloradd ("gray19", 0x00303030);
  coloradd ("grey19", 0x00303030);
  coloradd ("gray20", 0x00333333);
  coloradd ("grey20", 0x00333333);
  coloradd ("gray21", 0x00363636);
  coloradd ("grey21", 0x00363636);
  coloradd ("gray22", 0x00383838);
  coloradd ("grey22", 0x00383838);
  coloradd ("gray23", 0x003b3b3b);
  coloradd ("grey23", 0x003b3b3b);
  coloradd ("gray24", 0x003d3d3d);
  coloradd ("grey24", 0x003d3d3d);
  coloradd ("gray25", 0x00404040);
  coloradd ("grey25", 0x00404040);
  coloradd ("gray26", 0x00424242);
  coloradd ("grey26", 0x00424242);
  coloradd ("gray27", 0x00454545);
  coloradd ("grey27", 0x00454545);
  coloradd ("gray28", 0x00474747);
  coloradd ("grey28", 0x00474747);
  coloradd ("gray29", 0x004a4a4a);
  coloradd ("grey29", 0x004a4a4a);
  coloradd ("gray30", 0x004d4d4d);
  coloradd ("grey30", 0x004d4d4d);
  coloradd ("gray31", 0x004f4f4f);
  coloradd ("grey31", 0x004f4f4f);
  coloradd ("gray32", 0x00525252);
  coloradd ("grey32", 0x00525252);
  coloradd ("gray33", 0x00545454);
  coloradd ("grey33", 0x00545454);
  coloradd ("gray34", 0x00575757);
  coloradd ("grey34", 0x00575757);
  coloradd ("gray35", 0x00595959);
  coloradd ("grey35", 0x00595959);
  coloradd ("gray36", 0x005c5c5c);
  coloradd ("grey36", 0x005c5c5c);
  coloradd ("gray37", 0x005e5e5e);
  coloradd ("grey37", 0x005e5e5e);
  coloradd ("gray38", 0x00616161);
  coloradd ("grey38", 0x00616161);
  coloradd ("gray39", 0x00636363);
  coloradd ("grey39", 0x00636363);
  coloradd ("gray40", 0x00666666);
  coloradd ("grey40", 0x00666666);
  coloradd ("gray41", 0x00696969);
  coloradd ("grey41", 0x00696969);
  coloradd ("gray42", 0x006b6b6b);
  coloradd ("grey42", 0x006b6b6b);
  coloradd ("gray43", 0x006e6e6e);
  coloradd ("grey43", 0x006e6e6e);
  coloradd ("gray44", 0x00707070);
  coloradd ("grey44", 0x00707070);
  coloradd ("gray45", 0x00737373);
  coloradd ("grey45", 0x00737373);
  coloradd ("gray46", 0x00757575);
  coloradd ("grey46", 0x00757575);
  coloradd ("gray47", 0x00787878);
  coloradd ("grey47", 0x00787878);
  coloradd ("gray48", 0x007a7a7a);
  coloradd ("grey48", 0x007a7a7a);
  coloradd ("gray49", 0x007d7d7d);
  coloradd ("grey49", 0x007d7d7d);
  coloradd ("gray50", 0x007f7f7f);
  coloradd ("grey50", 0x007f7f7f);
  coloradd ("gray51", 0x00828282);
  coloradd ("grey51", 0x00828282);
  coloradd ("gray52", 0x00858585);
  coloradd ("grey52", 0x00858585);
  coloradd ("gray53", 0x00878787);
  coloradd ("grey53", 0x00878787);
  coloradd ("gray54", 0x008a8a8a);
  coloradd ("grey54", 0x008a8a8a);
  coloradd ("gray55", 0x008c8c8c);
  coloradd ("grey55", 0x008c8c8c);
  coloradd ("gray56", 0x008f8f8f);
  coloradd ("grey56", 0x008f8f8f);
  coloradd ("gray57", 0x00919191);
  coloradd ("grey57", 0x00919191);
  coloradd ("gray58", 0x00949494);
  coloradd ("grey58", 0x00949494);
  coloradd ("gray59", 0x00969696);
  coloradd ("grey59", 0x00969696);
  coloradd ("gray60", 0x00999999);
  coloradd ("grey60", 0x00999999);
  coloradd ("gray61", 0x009c9c9c);
  coloradd ("grey61", 0x009c9c9c);
  coloradd ("gray62", 0x009e9e9e);
  coloradd ("grey62", 0x009e9e9e);
  coloradd ("gray63", 0x00a1a1a1);
  coloradd ("grey63", 0x00a1a1a1);
  coloradd ("gray64", 0x00a3a3a3);
  coloradd ("grey64", 0x00a3a3a3);
  coloradd ("gray65", 0x00a6a6a6);
  coloradd ("grey65", 0x00a6a6a6);
  coloradd ("gray66", 0x00a8a8a8);
  coloradd ("grey66", 0x00a8a8a8);
  coloradd ("gray67", 0x00ababab);
  coloradd ("grey67", 0x00ababab);
  coloradd ("gray68", 0x00adadad);
  coloradd ("grey68", 0x00adadad);
  coloradd ("gray69", 0x00b0b0b0);
  coloradd ("grey69", 0x00b0b0b0);
  coloradd ("gray70", 0x00b3b3b3);
  coloradd ("grey70", 0x00b3b3b3);
  coloradd ("gray71", 0x00b5b5b5);
  coloradd ("grey71", 0x00b5b5b5);
  coloradd ("gray72", 0x00b8b8b8);
  coloradd ("grey72", 0x00b8b8b8);
  coloradd ("gray73", 0x00bababa);
  coloradd ("grey73", 0x00bababa);
  coloradd ("gray74", 0x00bdbdbd);
  coloradd ("grey74", 0x00bdbdbd);
  coloradd ("gray75", 0x00bfbfbf);
  coloradd ("grey75", 0x00bfbfbf);
  coloradd ("gray76", 0x00c2c2c2);
  coloradd ("grey76", 0x00c2c2c2);
  coloradd ("gray77", 0x00c4c4c4);
  coloradd ("grey77", 0x00c4c4c4);
  coloradd ("gray78", 0x00c7c7c7);
  coloradd ("grey78", 0x00c7c7c7);
  coloradd ("gray79", 0x00c9c9c9);
  coloradd ("grey79", 0x00c9c9c9);
  coloradd ("gray80", 0x00cccccc);
  coloradd ("grey80", 0x00cccccc);
  coloradd ("gray81", 0x00cfcfcf);
  coloradd ("grey81", 0x00cfcfcf);
  coloradd ("gray82", 0x00d1d1d1);
  coloradd ("grey82", 0x00d1d1d1);
  coloradd ("gray83", 0x00d4d4d4);
  coloradd ("grey83", 0x00d4d4d4);
  coloradd ("gray84", 0x00d6d6d6);
  coloradd ("grey84", 0x00d6d6d6);
  coloradd ("gray85", 0x00d9d9d9);
  coloradd ("grey85", 0x00d9d9d9);
  coloradd ("gray86", 0x00dbdbdb);
  coloradd ("grey86", 0x00dbdbdb);
  coloradd ("gray87", 0x00dedede);
  coloradd ("grey87", 0x00dedede);
  coloradd ("gray88", 0x00e0e0e0);
  coloradd ("grey88", 0x00e0e0e0);
  coloradd ("gray89", 0x00e3e3e3);
  coloradd ("grey89", 0x00e3e3e3);
  coloradd ("gray90", 0x00e5e5e5);
  coloradd ("grey90", 0x00e5e5e5);
  coloradd ("gray91", 0x00e8e8e8);
  coloradd ("grey91", 0x00e8e8e8);
  coloradd ("gray92", 0x00ebebeb);
  coloradd ("grey92", 0x00ebebeb);
  coloradd ("gray93", 0x00ededed);
  coloradd ("grey93", 0x00ededed);
  coloradd ("gray94", 0x00f0f0f0);
  coloradd ("grey94", 0x00f0f0f0);
  coloradd ("gray95", 0x00f2f2f2);
  coloradd ("grey95", 0x00f2f2f2);
  coloradd ("gray96", 0x00f5f5f5);
  coloradd ("grey96", 0x00f5f5f5);
  coloradd ("gray97", 0x00f7f7f7);
  coloradd ("grey97", 0x00f7f7f7);
  coloradd ("gray98", 0x00fafafa);
  coloradd ("grey98", 0x00fafafa);
  coloradd ("gray99", 0x00fcfcfc);
  coloradd ("grey99", 0x00fcfcfc);
  coloradd ("gray100", 0x00ffffff);
  coloradd ("grey100", 0x00ffffff);
  coloradd ("darkgrey", 0x00a9a9a9);
  coloradd ("dark grey", 0x00a9a9a9);
  coloradd ("DarkGrey", 0x00a9a9a9);
  coloradd ("darkgray", 0x00a9a9a9);
  coloradd ("dark gray", 0x00a9a9a9);
  coloradd ("DarkGray", 0x00a9a9a9);
  coloradd ("darkblue", 0x0000008b);
  coloradd ("dark blue", 0x0000008b);
  coloradd ("DarkBlue", 0x0000008b);
  coloradd ("darkcyan", 0x00008b8b);
  coloradd ("dark cyan", 0x00008b8b);
  coloradd ("DarkCyan", 0x00008b8b);
  coloradd ("darkmagenta", 0x008b008b);
  coloradd ("dark magenta", 0x008b008b);
  coloradd ("DarkMagenta", 0x008b008b);
  coloradd ("darkred", 0x008b0000);
  coloradd ("dark red", 0x008b0000);
  coloradd ("DarkRed", 0x008b0000);
  coloradd ("lightgreen", 0x0090ee90);
  coloradd ("light green", 0x0090ee90);
  coloradd ("LightGreen", 0x0090ee90);

  /* drawing background color white */
  bgcr = 0xff;
  bgcg = 0xff;
  bgcb = 0xff;

  /* html color table of the color database above */
  if (option_colortable)
    {
      ilona ();
    }

  return;
}


/* -1 on unknown color name */
int
colorcode (const char *name)
{
  splay_tree_node spn = (splay_tree_node) 0;
  int n = 0;
  unsigned int red = 0;
  unsigned int green = 0;
  unsigned int blue = 0;
  if (name[0] == '#')
    {
      /* assume html color #rrggbb */
      n = sscanf (name, "#%02x%02x%02x", &red, &green, &blue);
      if (n != 3)
	{
	  return (-1);
	}
      return ((red << 16) | (green << 8) | blue);
    }

  spn = splay_tree_lookup ((splay_tree) gucolor, (splay_tree_key) name);

  if (spn)
    {
      return ((int) spn->value);
    }
  else
    {
      return ((int) -1);
    }
}

static void
coloradd (const char *name, int code)
{
  splay_tree_node spn = (splay_tree_node) 0;

  spn = splay_tree_insert (gucolor,	/* splay_tree */
			   (splay_tree_key) name, (splay_tree_value) code);

  if (spn)
    {
    }

  return;
}

/* The type of a function used to allocate memory for tree root and
   node structures.  The first argument is the number of bytes needed;
   the second is a data pointer the splay tree functions pass through
   to the allocator.  This function must never return zero.  */
static void *
ucolor_splay_tree_allocate_fn (size_t n, void *data)
{
  /* pacify gcc */
  if (data)
    {
    }
  return ((void *) mpool_pool_malloc (color_pool, (size_t) n));
}

/* The type of a function used to free memory allocated using the
   corresponding splay_tree_allocate_fn.  The first argument is the
   memory to be freed; the latter is a data pointer the splay tree
   functions pass through to the freer.  */
static void
ucolor_splay_tree_deallocate_fn (void *pointer, void *data)
{
  /* pacify gcc */
  if (data)
    {
    }
  if (pointer)
    {
    }
  return;
}

/* The type of a function used to deallocate any resources associated
   with the key.  */
static void
ucolor_splay_tree_delete_key_fn (splay_tree_key keydata)
{
  /* key is a (char *) deallocated via mpool() system */
  if (keydata)
    {
    }
  return;
}

/* The type of a function used to deallocate any resources associated
   with the value.  */
static void
ucolor_splay_tree_delete_value_fn (splay_tree_value valuedata)
{
  /* value is unused */
  if (valuedata)
    {
    }
  return;
}

static int
ilona2 (splay_tree_node n, void *data)
{
  char *name;
  int code;
  int r;
  int g;
  int b;
  FILE *f;
  f = (FILE *) data;
  name = (char *) n->key;
  code = (int) n->value;
  r = (code & 0x00ff0000) >> 16;
  g = (code & 0x0000ff00) >> 8;
  b = (code & 0x000000ff);
  fprintf (f,
	   " <tr><td class=\"ltable\">\"%s\"</td><td class=\"rtable\">#%02x%02x%02x</td><td bgcolor=\"#%02x%02x%02x\">&nbsp;</td></tr>\n",
	   name, r, g, b, r, g, b);
  return (0);
}

/* ilona */
static void
ilona (void)
{
  splay_tree_node spn;
  const char *head =
    "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
    "<html>\n"
    "<head>\n"
    "  <meta content=\"text/html; charset=ISO-8859-1\"\n"
    " http-equiv=\"Content-Type\">\n"
    "  <title>mooigraph-colors</title>\n"
    "</head>\n"
    "<body>\n"
    "<a href=\"https://code.google.com/p/mooigraph/\">https://code.google.com/p/mooigraph/</a><br>\n"
    "<br>\n" "mooigraph colornames as in X11 rgb.txt<br>\n" "<br>\n"
    "<table border=\"1\" cellspacing=\"1\" cellpadding=\"1\" width=\"100%\">\n";
  const char *tail = "</table>\n" "<br>\n" "</body>\n" "</html>\n";
  FILE *f;
  f = fopen ("mooigraph-colors.html", "w");
  if (f)
    {
      fprintf (f, "%s", head);
      spn = splay_tree_min (gucolor);
      if (spn)
	{
	}
      splay_tree_foreach (gucolor, ilona2, (void *) f);
      fprintf (f, "%s", tail);
      fclose (f);
    }
  return;
}

/* End. */
